import fetch from 'common/src/utils/fetch';
import baseUrl from './env';
import UTILS from "common/src/utils/utils";

// 交叉学科页面查询
function postListPage(data) {
  return fetch({
      url: baseUrl + "/interdiscipline/listPage",
      method: 'post',
      data
  });
}
// 根据学号查询学生信息
function getStudents(data) {
  return fetch({
      url: baseUrl + "/interdiscipline/getStudents?studentId=" + data,
      method: 'get'
  });
}
// 交叉学科页面新增
function interdisciplineAdd(data) {
  return fetch({
      url: baseUrl + "/interdiscipline/add",
      method: 'post',
      data
  });
}
// 交叉学科页面编辑
function interdisciplineEdit(data) {
  return fetch({
      url: baseUrl + "/interdiscipline/edit",
      method: 'post',
      data
  });
}
// 交叉学科页面查看详情
function interdisciplineDetail(data) {
  return fetch({
      url: baseUrl + "/interdiscipline/getDetail?id="+data,
      method: 'get'
  });
}
// 交叉学科页面下载模板
function importTemplate() {
  return fetch({
    url: baseUrl + "/interdiscipline/importTemplate",
    method: 'get',
    responseType: 'blob'
  }).then(res => {
    UTILS.downloadFile(res, '交叉学科导入模板.xlsx', 'application/vnd.ms-excel;charset=utf-8');
  });
}
// 交叉学科页面导入
function importExcel(data) {
  return fetch({
    url: baseUrl + "/interdiscipline/importExcel",
    method: 'post',
    data
  });
}
// 交叉学科页面删除
function importExcelDelete(data) {
  return fetch({
    url: baseUrl + "/interdiscipline/delete",
    method: 'post',
    data
  });
}
// 交叉学科页面导出
function interdisciplineExport(data) {
  return fetch({
    url: baseUrl + "/interdiscipline/excel/export",
    method: 'post',
    responseType: 'blob',
    data
  }).then(res => {
    UTILS.downloadFile(res, '交叉学科.xlsx', 'application/vnd.ms-excel;charset=utf-8');
  });
  // return fetch({
  //   url: baseUrl + "/interdiscipline/excel/export",
  //   method: 'post',
  //   data
  // });
}

export default {
  postListPage: postListPage,
  getStudents: getStudents,
  interdisciplineAdd: interdisciplineAdd,
  interdisciplineEdit: interdisciplineEdit,
  importTemplate: importTemplate,
  importExcel: importExcel,
  interdisciplineDetail: interdisciplineDetail,
  interdisciplineExport: interdisciplineExport,
  importExcelDelete: importExcelDelete,
};